﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Deloitte;
using Deloitte.Controls;

namespace myTunes.iTunes
{
    public partial class iTunesArtistsImporter : Form
    {
        public iTunesArtistsImporter()
        {
            InitializeComponent();
            Deloitte.ControlsHelper.FormatButtons(this, ControlsHelper.ButtonColorStyle.BlueFlat);
            Deloitte.DataGridViewHelper.FormatDataGridViews(this);
            Deloitte.DataGridViewHelper.AddErrorEventHandler(this);
            //move this to the backgroundworker
            DisplayItunesArtists();
            this.artistImporterBackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(artistImporterBackgroundWorker_RunWorkerCompleted);
        }

        void artistImporterBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            //display the artists
        }

        private void DisplayItunesArtists()
        {
            List<string> artistNames = ImportiTunesArtists();
            BindingList<SelectableiTunesArtist> artists = new BindingList<SelectableiTunesArtist>();
            foreach (string name in artistNames)
            {
                artists.Add(new SelectableiTunesArtist(name));
            }
            BindingListFilterDataGridViewControl<SelectableiTunesArtist> artistFilterControl = new BindingListFilterDataGridViewControl<SelectableiTunesArtist>(artists, "IsSelected");
            artistFilterControl.Dock = DockStyle.Fill;
            this.artistsPanel.Controls.Add(artistFilterControl);
        }

        private static List<string> ImportiTunesArtists()
        {
            List<string> artistNames = Deloitte.iTunes.iTunesUtility.GetAllArtists();
            return artistNames;
        }

        private void selectAllButton_Click(object sender, EventArgs e)
        {
            
        }
    }
}
